//
//  Setting_AboutUsViewController.m
//  fxxiaoke
//
//  Created by 褚夫银 on 16/9/21.
//  Copyright © 2016年 jc. All rights reserved.
//

#import "Setting_AboutUsViewController.h"

#import "Setting_AboutUsTableViewCell.h"
#import "New_VersionIntroduceViewController.h"
#import "Dimensional_UploadViewController.h"

@interface Setting_AboutUsViewController () <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView * tableView;

@property (nonatomic, strong) UIView * view_head;

@property (nonatomic, strong) UILabel * version_number;

@end

@implementation Setting_AboutUsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self p_navi];
    
    [self p_setupView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navi
- (void )p_navi
{
    _btnLeft.hidden = YES;
    _lblLeft.hidden = YES;
    _btnRight.hidden = YES;
    _lblRight.hidden = YES;
    
    _lblTitle.text = @"关于XXXX";
    
    //左返回
    UIImageView * image_LeftRetrun = [[UIImageView alloc] initWithFrame:CGRectMake(11, 31.5, 25, 25)];
    image_LeftRetrun.userInteractionEnabled = YES;
    image_LeftRetrun.image = [UIImage imageNamed:@"Left-return.png"];
    [_topView addSubview:image_LeftRetrun];
    
    UILabel * lbl_return = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_LeftRetrun.frame) - 6, 35, 35, 15)];
    lbl_return.text = @"返回";
    lbl_return.textColor = [UIColor whiteColor];
    lbl_return.font = [UIFont systemFontOfSize:17];
    [_topView addSubview:lbl_return];
    
    UIButton * btn_return = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_return.frame = CGRectMake(10, 22, 60, 40);
    [_topView addSubview:btn_return];
    [btn_return addTarget:self action:@selector(btn_returnAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

//左返回
- (void )btn_returnAction:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

//显示tabbar
- (void )viewWillAppear:(BOOL)animated
{
    [(AppDelegate *)[[UIApplication sharedApplication] delegate] hiddenTabBar];
}

#pragma mark - 布局
- (void )p_setupView
{
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64) style:(UITableViewStylePlain)];
    self.tableView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.showsVerticalScrollIndicator = NO;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    //头视图
    [self p_headView];
    self.tableView.tableHeaderView = self.view_head;
    self.tableView.tableFooterView = [[UIView alloc] init];
    [self.view addSubview:self.tableView];
    
    //注册
    [self.tableView registerClass:[Setting_AboutUsTableViewCell class] forCellReuseIdentifier:@"aboutUs"];
}

#pragma mark - tableview代理
- (NSInteger )numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}

- (UITableViewCell * )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    Setting_AboutUsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"aboutUs" forIndexPath:indexPath];
    
    switch (indexPath.row)
    {
        case 0:
        {
            cell.name.text = @"新版本介绍";
        }
            break;
        case 1:
        {
            cell.name.text = @"给我评分";
        }
            break;
        case 2:
        {
            cell.name.text = @"扫描二维码下载";
        }
            break;
        default:
            break;
    }
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    switch (indexPath.row)
    {
        case 0:
        {
//            NSLog(@"新版本介绍");
            New_VersionIntroduceViewController * new_VersionIntroduceViewController = [[New_VersionIntroduceViewController alloc] init];
            [self showViewController:new_VersionIntroduceViewController sender:nil];
        }
            break;
        case 1:
        {
//            NSLog(@"给我评分");
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://itunes.apple.com/gb/app/yi-dong-cai-bian/id391945719?mt=8"]];
        }
            break;
        case 2:
        {
//            NSLog(@"扫描二维码下载");
            Dimensional_UploadViewController * dimensional_UploadViewController = [[Dimensional_UploadViewController alloc] init];
            [self showViewController:dimensional_UploadViewController sender:nil];
        }
            break;
        default:
            break;
    }
}

#pragma mark - 头视图
- (void )p_headView
{
    self.view_head = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 180)];
    
    //图片
    UIImageView * image_Pic = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 2 - 35, 30, 70, 70)];
    image_Pic.image = [UIImage imageNamed:@"Timg_pic.jpg"];
    image_Pic.layer.cornerRadius = 7;
    image_Pic.layer.masksToBounds = YES;
    [self.view_head addSubview:image_Pic];
    
    UILabel * lbl_Iphone = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(image_Pic.frame) + 15, SCREEN_WIDTH - 30, 20)];
    lbl_Iphone.text = @"纷享销客 for iPhone";
    lbl_Iphone.textAlignment = NSTextAlignmentCenter;
    lbl_Iphone.font = [UIFont systemFontOfSize:17.0f];
    lbl_Iphone.textColor = [UIColor grayColor];
    [self.view_head addSubview:lbl_Iphone];
    
    self.version_number = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(lbl_Iphone.frame) + 10, SCREEN_WIDTH - 30, 15)];
    self.version_number.text = @"版本号 V5.4.0";
    self.version_number.textColor = [UIColor grayColor];
    self.version_number.font = [UIFont systemFontOfSize:15.0f];
    self.version_number.textAlignment = NSTextAlignmentCenter;
    [self.view_head addSubview:self.version_number];
}


















@end
